package com.cqjtu.eecs.controller;

import com.cqjtu.eecs.entity.vo.ClassAnalysisVo;
import com.cqjtu.eecs.entity.vo.RadarGraphVo;
import com.cqjtu.eecs.entity.vo.StudentAnalysis;
import com.cqjtu.eecs.entity.vo.StudentAnalysisVo;
import com.cqjtu.eecs.exception.ParamsErrorException;
import com.cqjtu.eecs.service.IAnalysisService;
import com.cqjtu.eecs.service.IRequirementService;
import com.cqjtu.eecs.utils.Assert;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: 雷达图前端控制器
 * @author: 徐文升
 * @create: 2022-03-16 10:15
 **/

@RestController
@RequestMapping("/radar")
@Api(tags = "雷达图接口")
public class RadarController {

    @Autowired
    private IRequirementService requirementService;

    @Autowired
    private IAnalysisService analysisService;

    @GetMapping(value = "/requirement/{className}/{grade}/{majorName}")
    @ApiOperation(value = "获取自然班的毕业要求达成度雷达图数据")
    public List<RadarGraphVo> getRadarGraphData(@PathVariable String className, @PathVariable Integer grade, @PathVariable String majorName) {
        Assert.notBlank(className, new ParamsErrorException("班级名称不能为空"));
        Assert.notNull(grade, new ParamsErrorException("年级不能为空"));
        Assert.notBlank(majorName, new ParamsErrorException("专业名称不能为空"));

        return requirementService.getRadarGraphData(className, grade, majorName);
    }

    @GetMapping(value = "/analysis/{className}/{grade}/{majorCode}")
    @ApiOperation(value = "自然班毕业要求达成度整体分析")
    public ClassAnalysisVo getClassAnalysis(@PathVariable String className, @PathVariable Integer grade, @PathVariable String majorCode) {
        Assert.notBlank(className, new ParamsErrorException("班级名称不能为空"));
        Assert.notNull(grade, new ParamsErrorException("年级不能为空"));
        Assert.notBlank(majorCode, new ParamsErrorException("专业名称不能为空"));
        return analysisService.getClassAnalysis(className, grade, majorCode);
    }

    @GetMapping(value = "/student/{studentCode}")
    @ApiOperation(value = "根据学号查询学生毕业要求雷达图数据")
    public StudentAnalysisVo getStudentRadarGraphData(@PathVariable String studentCode) {
        Assert.notBlank(studentCode, new ParamsErrorException("学号不能为空"));
        return analysisService.getStudentRadarGraphData(studentCode);
    }
}
